import "thinkjs3-ts";

import routerREST from 'think-router-rest'
import path from "path";
const isDev = think.env === "development";


export = [
  {
    handle: "meta",
    options: {
      logRequest: isDev,
      sendResponseTime: isDev,
    },
  },
  {
    handle: "resource",
    enable:isDev,
    options: {
      root: path.join(think.ROOT_PATH, "www"),
      publicPath: /^\/(static|favicon\.ico)/,
    },
  },
  {
    handle: "trace",
    enable: !think.isCli,
    options: {
      debug: isDev,
      templates: {
        404: () => {
          return { a: "222" };
        },
      },
    },
  },
  {
    handle: "payload",
    options: {
      uploadDir: path.join(think.RUNTIME_PATH, "_tmp"),
      keepExtensions: true,
      limit: "5mb",
    },
  },
  {
    handle: "router",
    options: {
      defaultModule: "api",
      defaultController: "index",
      defaultAction: "index",
    },
  },
  { handle: routerREST, options: {} }, // RESTful 路由  GET /user  POST /user
  "logic",
  "controller",
];
